package org.jeecg.modules.inspect.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.inspect.entity.InsRule;
import org.jeecg.modules.inspect.mapper.InsRuleDutyMapper;
import org.jeecg.modules.inspect.mapper.InsRuleLineMapper;
import org.jeecg.modules.inspect.mapper.InsRuleMapper;
import org.jeecg.modules.inspect.service.IInsRuleService;
import org.jeecg.modules.system.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.Collection;

/**
 * @Description: 配置规则
 * @Author: jeecg-boot
 * @Date:   2023-11-24
 * @Version: V1.0
 */
@Service
public class InsRuleServiceImpl extends ServiceImpl<InsRuleMapper, InsRule> implements IInsRuleService {

	@Autowired
	private InsRuleMapper insRuleMapper;
	@Autowired
	private InsRuleLineMapper insRuleLineMapper;
	@Autowired
	private InsRuleDutyMapper insRuleDutyMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		insRuleLineMapper.deleteByMainId(id);
		insRuleDutyMapper.deleteByMainId(id);
		insRuleMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			insRuleLineMapper.deleteByMainId(id.toString());
			insRuleDutyMapper.deleteByMainId(id.toString());
			insRuleMapper.deleteById(id);
		}
	}
	
}
